﻿using BLL;
//********************************************************************************//
//创建日期：<创建日期，2016-05-12>
//创建作者：<孙雪婷，sunxueting@shanghai3h.com>
//功能说明：计划查询_查看详情
//********************************************************************************//
using BLL.Access;
using System;
using System.Data;
using System.Web;

namespace Web.Pages.YongShui._12.ChaXunGL
{
    public partial class JiHuaCX_CKLJ : BasePage
    {
        /// <summary>
        /// tab页签
        /// </summary>
        private string TabStr;
        
        /// <summary>
        /// 站点
        /// </summary>
        private string ZhanDian;

        /// <summary>
        /// 管理块
        /// </summary>
        private string GuanLiK;
        
        /// <summary>
        /// 水量年月
        /// </summary>
        private string YM;

        /// <summary>
        /// 0 用户号，1 用户名，2 用户地址
        /// </summary>
        private int Name;

        /// <summary>
        /// 用户信息
        /// </summary>
        private string Value;

        /// </summary>
        /// 用户信息bll
        /// </summary>
        YS_YG_YONGHUXXBLL _YS_YG_YONGHUXXBLL = new YS_YG_YONGHUXXBLL();
        /// <summary>
        /// 存储过程调用类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();

        protected void Page_Load(object sender, EventArgs e)
        {
            this.TabStr = this.Request.QueryString["TabStr"];
            this.ZhanDian = HttpUtility.UrlDecode(this.Request.QueryString["zhandian"]);
            this.GuanLiK = HttpUtility.UrlDecode(this.Request.QueryString["guanlik"]);
            this.YM = this.Request.QueryString["ym"];
            this.Name = this.Request.QueryString["name"] != "" ? Convert.ToInt32(this.Request.QueryString["name"]) : -1;
            int id = Convert.ToInt32(HttpUtility.UrlDecode(this.Request.QueryString["value"]));
            DataTable DTYH = _YS_YG_YONGHUXXBLL.SelectYS_YG_YONGHUXXesDynamic(string.Format("ID={0}", id), null);
            this.Value = DTYH.Rows.Count > 0 ? DTYH.Rows[0]["S_YONGHUH"].ToString() : "";
            switch (this.TabStr)
            {
                case "tab2":
                    LoadTab2_LeiJi();
                    break;
                case "tab3":
                    LoadTab3_LeiJi();
                    break;
                case "tab4":
                    LoadTab4_LeiJi();
                    break;
                case "tab5":
                    LoadTab5_LeiJi();
                    break;
                default:
                    break;

            }
        }

        /// <summary>
        /// 下达计划全年累计
        /// </summary>
        private void LoadTab2_LeiJi() 
        {
            int I_Y = Convert.ToInt32(this.YM) / 100;
            int i_m1_total = 0, i_m2_total = 0, i_m3_total = 0, i_m4_total = 0, i_m5_total = 0, i_m6_total = 0,
                i_m7_total = 0, i_m8_total = 0, i_m9_total = 0, i_m10_total = 0, i_m11_total = 0, i_m12_total = 0,
                i_heji = 0;
            DataTable dt = _SpHelper.P_YSCX_JHCX_ALL(1, I_Y, null, this.Value).Tables[0];          
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                i_m1_total += Convert.ToInt32(dt.Rows[i]["I_M1"]);
                i_m2_total += Convert.ToInt32(dt.Rows[i]["I_M2"]);
                i_m3_total += Convert.ToInt32(dt.Rows[i]["I_M3"]);
                i_m4_total += Convert.ToInt32(dt.Rows[i]["I_M4"]);
                i_m5_total += Convert.ToInt32(dt.Rows[i]["I_M5"]);
                i_m6_total += Convert.ToInt32(dt.Rows[i]["I_M6"]);
                i_m7_total += Convert.ToInt32(dt.Rows[i]["I_M7"]);
                i_m8_total += Convert.ToInt32(dt.Rows[i]["I_M8"]);
                i_m9_total += Convert.ToInt32(dt.Rows[i]["I_M9"]);
                i_m10_total += Convert.ToInt32(dt.Rows[i]["I_M10"]);
                i_m11_total += Convert.ToInt32(dt.Rows[i]["I_M11"]);
                i_m12_total += Convert.ToInt32(dt.Rows[i]["I_M12"]);
                i_heji += Convert.ToInt32(dt.Rows[i]["I_HEJI"]);
            }
            txtYiYue.Text = i_m1_total.ToString();
            txtErYue.Text = i_m2_total.ToString();
            txtSanYue.Text = i_m3_total.ToString();
            txtSiYue.Text = i_m4_total.ToString();
            txtWuYue.Text = i_m5_total.ToString();
            txtLiuYue.Text = i_m6_total.ToString();
            txtQiYue.Text = i_m7_total.ToString();
            txtBaYue.Text = i_m8_total.ToString();
            txtJiuYue.Text = i_m9_total.ToString();
            txtShiYue.Text = i_m10_total.ToString();
            txtShiYiYue.Text = i_m11_total.ToString();
            txtShiErYue.Text = i_m12_total.ToString();
            txtQuanNianHJ.Text = i_heji.ToString();
        }
        /// <summary>
        /// 查看原计划全年累计
        /// </summary>
        private void LoadTab3_LeiJi() 
        {
            int I_Y = Convert.ToInt32(this.YM) / 100;
            int I_M = Convert.ToInt32(this.YM) % 100;
            int i_m1_total = 0, i_m2_total = 0, i_m3_total = 0, i_m4_total = 0, i_m5_total = 0, i_m6_total = 0,
                i_m7_total = 0, i_m8_total = 0, i_m9_total = 0, i_m10_total = 0, i_m11_total = 0, i_m12_total = 0,
                i_heji = 0;
            DataTable dt = _SpHelper.P_YSCX_JHCX_YJH(this.ZhanDian, this.GuanLiK, I_Y, this.Name, this.Value, I_M, 0).Tables[0];
            for (int i = 0; i < dt.Rows.Count;i++ ) 
            {
                i_m1_total += Convert.ToInt32(dt.Rows[i]["I_M1"]);
                i_m2_total += Convert.ToInt32(dt.Rows[i]["I_M2"]);
                i_m3_total += Convert.ToInt32(dt.Rows[i]["I_M3"]);
                i_m4_total += Convert.ToInt32(dt.Rows[i]["I_M4"]);
                i_m5_total += Convert.ToInt32(dt.Rows[i]["I_M5"]);
                i_m6_total += Convert.ToInt32(dt.Rows[i]["I_M6"]);
                i_m7_total += Convert.ToInt32(dt.Rows[i]["I_M7"]);
                i_m8_total += Convert.ToInt32(dt.Rows[i]["I_M8"]);
                i_m9_total += Convert.ToInt32(dt.Rows[i]["I_M9"]);
                i_m10_total += Convert.ToInt32(dt.Rows[i]["I_M10"]);
                i_m11_total += Convert.ToInt32(dt.Rows[i]["I_M11"]);
                i_m12_total += Convert.ToInt32(dt.Rows[i]["I_M12"]);
                i_heji += Convert.ToInt32(dt.Rows[i]["I_HEJI"]);
            }
            txtYiYue.Text = i_m1_total.ToString();
            txtErYue.Text = i_m2_total.ToString();
            txtSanYue.Text = i_m3_total.ToString();
            txtSiYue.Text = i_m4_total.ToString();
            txtWuYue.Text = i_m5_total.ToString();
            txtLiuYue.Text = i_m6_total.ToString();
            txtQiYue.Text = i_m7_total.ToString();
            txtBaYue.Text = i_m8_total.ToString();
            txtJiuYue.Text = i_m9_total.ToString();
            txtShiYue.Text = i_m10_total.ToString();
            txtShiYiYue.Text =i_m11_total.ToString();
            txtShiErYue.Text =i_m12_total.ToString();
            txtQuanNianHJ.Text = i_heji.ToString();

        }

        /// <summary>
        /// 基建计划全年累计
        /// </summary>
        private void LoadTab4_LeiJi() 
        {
            int I_Y = Convert.ToInt32(this.YM) / 100;
            int i_m1_total = 0, i_m2_total = 0, i_m3_total = 0, i_m4_total = 0, i_m5_total = 0, i_m6_total = 0,
                i_m7_total = 0, i_m8_total = 0, i_m9_total = 0, i_m10_total = 0, i_m11_total = 0, i_m12_total = 0,
                i_heji = 0;
            DataTable dt = _SpHelper.P_YSCX_JHCX_ALL(2, I_Y, null, this.Value).Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                i_m1_total += Convert.ToInt32(dt.Rows[i]["I_M1"]);
                i_m2_total += Convert.ToInt32(dt.Rows[i]["I_M2"]);
                i_m3_total += Convert.ToInt32(dt.Rows[i]["I_M3"]);
                i_m4_total += Convert.ToInt32(dt.Rows[i]["I_M4"]);
                i_m5_total += Convert.ToInt32(dt.Rows[i]["I_M5"]);
                i_m6_total += Convert.ToInt32(dt.Rows[i]["I_M6"]);
                i_m7_total += Convert.ToInt32(dt.Rows[i]["I_M7"]);
                i_m8_total += Convert.ToInt32(dt.Rows[i]["I_M8"]);
                i_m9_total += Convert.ToInt32(dt.Rows[i]["I_M9"]);
                i_m10_total += Convert.ToInt32(dt.Rows[i]["I_M10"]);
                i_m11_total += Convert.ToInt32(dt.Rows[i]["I_M11"]);
                i_m12_total += Convert.ToInt32(dt.Rows[i]["I_M12"]);
                i_heji += Convert.ToInt32(dt.Rows[i]["I_HEJI"]);
            }
            txtYiYue.Text = i_m1_total.ToString();
            txtErYue.Text = i_m2_total.ToString();
            txtSanYue.Text = i_m3_total.ToString();
            txtSiYue.Text = i_m4_total.ToString();
            txtWuYue.Text = i_m5_total.ToString();
            txtLiuYue.Text = i_m6_total.ToString();
            txtQiYue.Text = i_m7_total.ToString();
            txtBaYue.Text = i_m8_total.ToString();
            txtJiuYue.Text = i_m9_total.ToString();
            txtShiYue.Text = i_m10_total.ToString();
            txtShiYiYue.Text = i_m11_total.ToString();
            txtShiErYue.Text = i_m12_total.ToString();
            txtQuanNianHJ.Text = i_heji.ToString();
        }

        private void LoadTab5_LeiJi() { }
    }
}